<template>
  <div class="tab_bar_container">
    <div class="tab_bar_wrapper">
      <TabbarItem v-for="(item,index) in tabbarItems"
      :key="index"
      :item="item"
      :index="index"
      :selectIndex="selectIndex"
      @changeSelectIndex="changeSelectIndex"/>
    </div>
  </div>
</template>

<script>
import TabbarItem from "./TabbarItem";

export default {
  components:{
    TabbarItem
  },
  props:{
    items:{
      type:Array,
      required:true,
      validator:function(value){
        return value.length <=  6
      }
    },
    defaultSelectIndex:{
      type:Number,
      default:0
    }
  },
  data(){
    return{
      tabbarItems:this.items,
      selectIndex:this.defaultSelectIndex
    }
  },
  methods:{
    changeSelectIndex(index){
      console.log(index)
      this.selectIndex = index
    }
  }
}
</script>

<style scoped>
.tab_bar_container
{
  width: 100%;
  height: 64px;
  position: fixed;
  left: 0px;
  bottom: 0px;
  border-top: 1px solid lightgray;
  /* background-color: red; */
}

.tab_bar_wrapper
{
  width: 100%;
  height: 64px;
  display: inline-flex;
  justify-content: space-around;
  align-items: center;
}
</style>